#include <stdio.h>
#include <string.h>

int  is_s1(char s1[], char s[]);

int main() {
	char s1[] = "AABCD";
	char s2[100];
	gets(s2);

	printf("%d", is_s1(s1, s2));

	return 0;
}

int  is_s1(char s1[], char s[]) {
	int len = strlen(s);
	for (int i = 0; i <= len - 1; i++) {
		int first = s[0];
		int j = 0;
		for (j = 0; j < len - 1; j++) {
			s[j] = s[j + 1];
		}
		s[j] = first;
		if (strcmp(s1, s) == 0) {
			return 1;
		}
	}
	return 0;
}